package com.bootdo.clouddo.service.book.impl;

import com.bootdo.clouddo.dao.book.BookCategoryMapper;
import com.bootdo.clouddo.domain.book.BookCategory;
import com.bootdo.clouddo.service.book.IBookCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class BookCategoryServiceImpl implements IBookCategoryService {

    @Autowired
    private BookCategoryMapper dao;

    @Override
    public int save(BookCategory category) {
        if(dao.existsWithPrimaryKey(category.getId())) {
            category.setUpdateTime(new Date());
            return dao.updateByPrimaryKeySelective(category);
        }
        return dao.insertSelective(category);
    }
}
